Skip to content

Commit f480837

Browse files
committed
Do not constrain result types only if the inlineable is transparent
1 parent 1e7bf82 commit f480837

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import Inferencing.*
1717
import ErrorReporting.*
1818
import util.SourceFile
1919
import TypeComparer.necessarySubType
20+
import dotty.tools.dotc.core.Flags.Transparent
2021

2122
import scala.annotation.internal.sharable
2223

@@ -105,14 +106,14 @@ object ProtoTypes {
105106
if !res then ctx.typerState.constraint = savedConstraint
106107
res
107108

108-
/** Constrain result with special case if `meth` is an inlineable method in an inlineable context.
109+
/** Constrain result with special case if `meth` is a transparent inlineable method in an inlineable context.
109110
* In that case, we should always succeed and not constrain type parameters in the expected type,
110111
* because the actual return type can be a subtype of the currently known return type.
111112
* However, we should constrain parameters of the declared return type. This distinction is
112113
* achieved by replacing expected type parameters with wildcards.
113114
*/
114115
def constrainResult(meth: Symbol, mt: Type, pt: Type)(using Context): Boolean =
115-
if (Inlines.isInlineable(meth)) {
116+
if (Inlines.isInlineable(meth) && meth.is(Transparent)) {
116117
constrainResult(mt, wildApprox(pt))
117118
true
118119
}

0 commit comments

Comments
 (0)