File tree 1 file changed +17
-5
lines changed
compiler/src/dotty/tools/dotc/typer
1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import Decorators.*
13
13
import Uniques .*
14
14
import Flags .{Method , Transparent }
15
15
import inlines .Inlines
16
+ import config .{Feature , SourceVersion }
16
17
import config .Printers .typr
17
18
import Inferencing .*
18
19
import ErrorReporting .*
@@ -128,11 +129,22 @@ object ProtoTypes {
128
129
case _ =>
129
130
false
130
131
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
+ }
136
148
137
149
end constrainResult
138
150
end Compatibility
You can’t perform that action at this time.
0 commit comments