File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import Decorators.*
1313import Uniques .*
1414import Flags .{Method , Transparent }
1515import inlines .Inlines
16+ import config .{Feature , SourceVersion }
1617import config .Printers .typr
1718import Inferencing .*
1819import 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
You can’t perform that action at this time.
0 commit comments