Skip to content

Commit 44d6932

Browse files
oderskynoti0na1
authored andcommitted
Re-instantiate previous behavior also for LTS
1 parent ad29d1b commit 44d6932

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

+17-5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Decorators.*
1313
import Uniques.*
1414
import Flags.{Method, Transparent}
1515
import inlines.Inlines
16+
import config.{Feature, SourceVersion}
1617
import config.Printers.typr
1718
import Inferencing.*
1819
import ErrorReporting.*
@@ -128,11 +129,22 @@ object ProtoTypes {
128129
case _ =>
129130
false
130131

131-
if Inlines.isInlineable(meth) && meth.is(Transparent) then
132-
constrainResult(mt, wildApprox(pt))
133-
true
134-
else
135-
constFoldException(pt) || constrainResult(mt, pt)
132+
constFoldException(pt) || {
133+
if Inlines.isInlineable(meth) then
134+
// Stricter behaviour in 3.4+: do not apply `wildApprox` to non-transparent inlines
135+
if Feature.sourceVersion.isAtLeast(SourceVersion.`3.4`) then
136+
if meth.is(Transparent) then
137+
constrainResult(mt, wildApprox(pt))
138+
// do not constrain the result type of transparent inline methods
139+
true
140+
else
141+
constrainResult(mt, pt)
142+
else
143+
// Best-effort to fix https://github.com/scala/scala3/issues/9685 in the 3.3.x series
144+
// while preserving source compatibility as much as possible
145+
constrainResult(mt, wildApprox(pt)) || meth.is(Transparent)
146+
else constrainResult(mt, pt)
147+
}
136148

137149
end constrainResult
138150
end Compatibility

0 commit comments

Comments
 (0)