File tree 3 files changed +12
-5
lines changed
compiler/src/dotty/tools/dotc
3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -532,7 +532,7 @@ object Contexts {
532
532
moreProperties = Map .empty
533
533
typeComparer = new TypeComparer (this )
534
534
searchHistory = new SearchHistory (0 , Map ())
535
- gadt = new GADTMap ( SimpleMap . Empty ) // EmptyGADTMap
535
+ gadt = EmptyGADTMap
536
536
}
537
537
538
538
@ sharable object NoContext extends Context {
Original file line number Diff line number Diff line change @@ -256,7 +256,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTrans
256
256
case tree @ Annotated (annotated, annot) =>
257
257
cpy.Annotated (tree)(transform(annotated), transformAnnot(annot))
258
258
case tree : AppliedTypeTree =>
259
- Checking .checkAppliedType(tree)
259
+ Checking .checkAppliedType(tree, boundsCheck = ! ctx.mode.is( Mode . Pattern ) )
260
260
super .transform(tree)
261
261
case SingletonTypeTree (ref) =>
262
262
Checking .checkRealizable(ref.tpe, ref.pos.focus)
@@ -282,7 +282,14 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTrans
282
282
}
283
283
super .transform(tree)
284
284
case Typed (Ident (nme.WILDCARD ), _) =>
285
- tree // skip checking pattern type
285
+ super .transform(tree)(ctx.addMode(Mode .Pattern ))
286
+ // The added mode signals that bounds in a pattern need not
287
+ // conform to selector bounds. I.e. assume
288
+ // type Tree[T >: Null <: Type]
289
+ // One is still allowed to write
290
+ // case x: Tree[_]
291
+ // (which translates to)
292
+ // case x: (_: Tree[_])
286
293
case tree =>
287
294
super .transform(tree)
288
295
}
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ object Checking {
68
68
* Unreducible applications correspond to general existentials, and we
69
69
* cannot handle those.
70
70
*/
71
- def checkAppliedType (tree : AppliedTypeTree )(implicit ctx : Context ) = {
71
+ def checkAppliedType (tree : AppliedTypeTree , boundsCheck : Boolean )(implicit ctx : Context ) = {
72
72
val AppliedTypeTree (tycon, args) = tree
73
73
// If `args` is a list of named arguments, return corresponding type parameters,
74
74
// otherwise return type parameters unchanged
@@ -81,7 +81,7 @@ object Checking {
81
81
val bounds = tparams.map(_.paramInfoAsSeenFrom(tycon.tpe).bounds)
82
82
def instantiate (bound : Type , args : List [Type ]) =
83
83
HKTypeLambda .fromParams(tparams, bound).appliedTo(args)
84
- checkBounds(orderedArgs, bounds, instantiate)
84
+ if (boundsCheck) checkBounds(orderedArgs, bounds, instantiate)
85
85
86
86
def checkWildcardApply (tp : Type , pos : Position ): Unit = tp match {
87
87
case tp @ AppliedType (tycon, args) if args.exists(_.isInstanceOf [TypeBounds ]) =>
You can’t perform that action at this time.
0 commit comments