Skip to content

Fix #2333: Check if class is deprecated #3811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 11, 2018

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

@allanrenucci
Copy link
Contributor

What about this instead?

diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala
index aaadbb66e..36ab320d7 100644
--- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala
+++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala
@@ -879,6 +879,7 @@ class RefChecks extends MiniPhase { thisPhase =>
   }
 
   override def transformNew(tree: New)(implicit ctx: Context) = {
+    checkUndesiredProperties(tree.tpe.typeSymbol, tree.pos)
     currentLevel.enterReference(tree.tpe.typeSymbol, tree.pos)
     tree
   }

@@ -879,6 +879,7 @@ class RefChecks extends MiniPhase { thisPhase =>
}

override def transformNew(tree: New)(implicit ctx: Context) = {
checkUndesiredProperties(tree.tpe.typeSymbol, tree.pos)
currentLevel.enterReference(tree.tpe.typeSymbol, tree.pos)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe store tree.tpe.typeSymbol in a temporary val


object Test {
new Foo // error
}
Copy link
Contributor

@allanrenucci allanrenucci Jan 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also slightly modify the test, to test secondary constructors:

@deprecated("bla", "2.11.0") class Foo {
  def this(x: Int) = this()
}

object Test {
  new Foo // error: deprecated
  new Foo(1) // error: deprecated
}

@allanrenucci
Copy link
Contributor

Sorry for the multiple paths 😄

@nicolasstucki nicolasstucki merged commit 82dd280 into scala:master Jan 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants