Skip to content

Commit f663a8b

Browse files
Revert broken changes with transparent inline (#19922)
Proposed in #19415 (comment) Fixes #19415 Reverts #18130 and #17924. #18130 is still closed as it was introduced by #17924. This reopens #9685
2 parents 02c2a6e + 5bc43d3 commit f663a8b

File tree

9 files changed

+5
-115
lines changed

9 files changed

+5
-115
lines changed

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

+3-18
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import Inferencing.*
1717
import ErrorReporting.*
1818
import util.SourceFile
1919
import TypeComparer.necessarySubType
20-
import dotty.tools.dotc.core.Flags.Transparent
21-
import dotty.tools.dotc.config.{ Feature, SourceVersion }
2220

2321
import scala.annotation.internal.sharable
2422
import dotty.tools.dotc.util.Spans.{NoSpan, Span}
@@ -108,29 +106,16 @@ object ProtoTypes {
108106
if !res then ctx.typerState.constraint = savedConstraint
109107
res
110108

111-
/** Constrain result with special case if `meth` is a transparent inlineable method in an inlineable context.
109+
/** Constrain result with special case if `meth` is an inlineable method in an inlineable context.
112110
* In that case, we should always succeed and not constrain type parameters in the expected type,
113111
* because the actual return type can be a subtype of the currently known return type.
114112
* However, we should constrain parameters of the declared return type. This distinction is
115113
* achieved by replacing expected type parameters with wildcards.
116114
*/
117115
def constrainResult(meth: Symbol, mt: Type, pt: Type)(using Context): Boolean =
118116
if (Inlines.isInlineable(meth)) {
119-
// Stricter behaviour in 3.4+: do not apply `wildApprox` to non-transparent inlines
120-
if (Feature.sourceVersion.isAtLeast(SourceVersion.`3.4`)) {
121-
if (meth.is(Transparent)) {
122-
constrainResult(mt, wildApprox(pt))
123-
// do not constrain the result type of transparent inline methods
124-
true
125-
} else {
126-
constrainResult(mt, pt)
127-
}
128-
} else {
129-
// Best-effort to fix https://github.com/scala/scala3/issues/9685 in the 3.3.x series
130-
// while preserving source compatibility as much as possible
131-
val methodMatchedType = constrainResult(mt, wildApprox(pt))
132-
meth.is(Transparent) || methodMatchedType
133-
}
117+
constrainResult(mt, wildApprox(pt))
118+
true
134119
}
135120
else constrainResult(mt, pt)
136121
}

tests/neg-macros/i18174.scala

-27
This file was deleted.

tests/neg-macros/i9685bis.check

-9
This file was deleted.

tests/neg-macros/i9685bis.scala

-23
This file was deleted.

tests/neg/i9685bis.check

-9
This file was deleted.

tests/neg/i9685bis.scala

-25
This file was deleted.

tests/pos-macros/i18123.scala renamed to tests/pos/i18123.scala

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// may not compile anymore in Scala 3.4+
22
package pkg
33

4-
import scala.language.`3.3`
5-
64
trait P[+T]
75

86
extension [T](inline parse0: P[T])

0 commit comments

Comments
 (0)