File tree Expand file tree Collapse file tree 2 files changed +32
-6
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -106,16 +106,18 @@ object ProtoTypes {
106
106
if ! res then ctx.typerState.constraint = savedConstraint
107
107
res
108
108
109
- /** Constrain result with special case if `meth` is a transparent inlineable method in an inlineable context.
110
- * In that case, we should always succeed and not constrain type parameters in the expected type,
111
- * because the actual return type can be a subtype of the currently known return type.
109
+ /** Constrain result with special case if `meth` is an inlineable method in an inlineable context.
110
+ * In that case, if the method is transparent we should always succeed and not constrain type
111
+ * parameters in the expected type, because the actual return type can be a subtype of the currently
112
+ * known return type.
112
113
* However, we should constrain parameters of the declared return type. This distinction is
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
+ val methodMatchedType = constrainResult(mt, wildApprox(pt))
119
+ // do not constrain the result type of transparent inline methods
120
+ meth.is(Transparent ) || methodMatchedType
119
121
}
120
122
else constrainResult(mt, pt)
121
123
}
Original file line number Diff line number Diff line change
1
+ package pkg
2
+
3
+ trait P [+ T ]
4
+
5
+ extension [T ](inline parse0 : P [T ])
6
+ inline def | [V >: T ](inline other : P [V ]): P [V ] = ???
7
+
8
+ extension [T ](inline parse0 : => P [T ])
9
+ inline def rep [V ](inline min : Int = 0 )(using repeater : Implicits .Repeater [T , V ]): P [V ] = ???
10
+
11
+ object Implicits :
12
+ trait Repeater [- T , R ]
13
+ object Repeater :
14
+ implicit def GenericRepeaterImplicit [T ]: Repeater [T , Seq [T ]] = ???
15
+
16
+ sealed trait RegexTree
17
+ abstract class Node extends RegexTree
18
+ class CharClassIntersection () extends Node
19
+
20
+ def classItem : P [RegexTree ] = ???
21
+ def charClassIntersection : P [CharClassIntersection ] = ???
22
+
23
+ def x =
24
+ (charClassIntersection.rep() | classItem.rep())
You can’t perform that action at this time.
0 commit comments