Skip to content

Commit

Permalink
Address reviewer comments
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Oct 4, 2017
1 parent 48ed3c6 commit 6929958
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ object Contexts {
moreProperties = Map.empty
typeComparer = new TypeComparer(this)
searchHistory = new SearchHistory(0, Map())
gadt = new GADTMap(SimpleMap.Empty) // EmptyGADTMap
gadt = EmptyGADTMap
}

@sharable object NoContext extends Context {
Expand Down
11 changes: 9 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/PostTyper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTrans
case tree @ Annotated(annotated, annot) =>
cpy.Annotated(tree)(transform(annotated), transformAnnot(annot))
case tree: AppliedTypeTree =>
Checking.checkAppliedType(tree)
Checking.checkAppliedType(tree, boundsCheck = !ctx.mode.is(Mode.Pattern))
super.transform(tree)
case SingletonTypeTree(ref) =>
Checking.checkRealizable(ref.tpe, ref.pos.focus)
Expand All @@ -282,7 +282,14 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTrans
}
super.transform(tree)
case Typed(Ident(nme.WILDCARD), _) =>
tree // skip checking pattern type
super.transform(tree)(ctx.addMode(Mode.Pattern))
// The added mode signals that bounds in a pattern need not
// conform to selector bounds. I.e. assume
// type Tree[T >: Null <: Type]
// One is still allowed to write
// case x: Tree[_]
// (which translates to)
// case x: (_: Tree[_])
case tree =>
super.transform(tree)
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ object Checking {
* Unreducible applications correspond to general existentials, and we
* cannot handle those.
*/
def checkAppliedType(tree: AppliedTypeTree)(implicit ctx: Context) = {
def checkAppliedType(tree: AppliedTypeTree, boundsCheck: Boolean)(implicit ctx: Context) = {
val AppliedTypeTree(tycon, args) = tree
// If `args` is a list of named arguments, return corresponding type parameters,
// otherwise return type parameters unchanged
Expand All @@ -81,7 +81,7 @@ object Checking {
val bounds = tparams.map(_.paramInfoAsSeenFrom(tycon.tpe).bounds)
def instantiate(bound: Type, args: List[Type]) =
HKTypeLambda.fromParams(tparams, bound).appliedTo(args)
checkBounds(orderedArgs, bounds, instantiate)
if (boundsCheck) checkBounds(orderedArgs, bounds, instantiate)

def checkWildcardApply(tp: Type, pos: Position): Unit = tp match {
case tp @ AppliedType(tycon, args) if args.exists(_.isInstanceOf[TypeBounds]) =>
Expand Down

0 comments on commit 6929958

Please sign in to comment.