@@ -18,6 +18,7 @@ import ErrorReporting.*
18
18
import util .SourceFile
19
19
import TypeComparer .necessarySubType
20
20
import dotty .tools .dotc .core .Flags .Transparent
21
+ import dotty .tools .dotc .config .{ Feature , SourceVersion }
21
22
22
23
import scala .annotation .internal .sharable
23
24
@@ -113,9 +114,22 @@ object ProtoTypes {
113
114
* achieved by replacing expected type parameters with wildcards.
114
115
*/
115
116
def constrainResult (meth : Symbol , mt : Type , pt : Type )(using Context ): Boolean =
116
- if (Inlines .isInlineable(meth) && meth.is(Transparent )) {
117
- constrainResult(mt, wildApprox(pt))
118
- true
117
+ if (Inlines .isInlineable(meth)) {
118
+ // Stricter behaviour in 3.4+: do not apply `wildApprox` to non-transparent inlines
119
+ if (Feature .sourceVersion.isAtLeast(SourceVersion .future)) {
120
+ if (meth.is(Transparent )) {
121
+ constrainResult(mt, wildApprox(pt))
122
+ // do not constrain the result type of transparent inline methods
123
+ true
124
+ } else {
125
+ constrainResult(mt, pt)
126
+ }
127
+ } else {
128
+ // Best-effort to fix https://github.com/lampepfl/dotty/issues/9685 in the 3.3.x series
129
+ // while preserving source compatibility as much as possible
130
+ val methodMatchedType = constrainResult(mt, wildApprox(pt))
131
+ meth.is(Transparent ) || methodMatchedType
132
+ }
119
133
}
120
134
else constrainResult(mt, pt)
121
135
}
0 commit comments