Skip to content
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

No deprecation warnings for type references #9825

Closed
bishabosha opened this issue Sep 18, 2020 · 7 comments · May be fixed by #14586
Closed

No deprecation warnings for type references #9825

bishabosha opened this issue Sep 18, 2020 · 7 comments · May be fixed by #14586

Comments

@bishabosha
Copy link
Member

Minimized code

object Module {
  @deprecated("Module.Foo is deprecated")
  type Foo[+A] = scala.List[A]
}

object Test {
  val m: Module.Foo[String] = List("wow")
}

Output

// it compiles

Expectation

in scala 2.13.4 we see

Deprecated.scala:7: warning: type Foo in object Module is deprecated: Module.Foo is deprecated
  val m: Module.Foo[String] = List("wow")
                ^
1 warning
@bishabosha
Copy link
Member Author

bishabosha commented Oct 30, 2020

deprecation checks are currently done in refchecks, but it will never see the alias Module.Foo - as it is dealiased by the time refchecks occurs: (see val m: List[String])

// with -Xprint:firstTransform
package <empty> {
  final lazy module val Module: Module$ = new Module$()
  @scala.annotation.internal.SourceFile("tests/neg/i9825.scala") final module 
    class
   Module$() extends Object() {
    private def writeReplace(): AnyRef = 
      new scala.runtime.ModuleSerializationProxy(classOf[Module.type])
    @deprecated("Module.Foo is deprecated", 
      deprecated.$lessinit$greater$default$2
    ) type Foo = List
  }
  final lazy module val Test: Test$ = new Test$()
  @scala.annotation.internal.SourceFile("tests/neg/i9825.scala") final module 
    class
   Test$() extends Object() {
    private def writeReplace(): AnyRef = 
      new scala.runtime.ModuleSerializationProxy(classOf[Test.type])
    val m: List[String] = List.apply[String](["wow" : String]:String*)
  }
}

@smarter
Copy link
Member

smarter commented Nov 2, 2020

In some situation we don't dealias type applications because it changes type inference, you could try expanding that set of conditions to include situations where the type has annotations:
https://github.com/lampepfl/dotty/blob/8e9ac7519b56a452348b878979f56ff01308cc8e/compiler/src/dotty/tools/dotc/core/TypeApplications.scala#L319-L325

@bishabosha
Copy link
Member Author

bishabosha commented Nov 3, 2020

@smarter that doesn't take into account type aliases without arguments, such as type Foo = String which are also dealiased at firstTransform - perhaps this is not meant to happen?

@smarter
Copy link
Member

smarter commented Nov 3, 2020

I don't know why those get dealiased at that point.

@bishabosha
Copy link
Member Author

bishabosha commented Nov 3, 2020

yes that was my mistake, it seems that the type of a Type tree referencing type Foo = String is String, so I would have to check that the symbol info is also not dealiased

@ckipp01
Copy link
Member

ckipp01 commented May 12, 2023

Maybe it's implied, but is it expected to see the deprecation warning even when not using -deprecation? Because testing with it I do see it when using the flag.

@smarter
Copy link
Member

smarter commented May 12, 2023

This got fixed by moving deprecation checks before FirstTransform in #17301

@smarter smarter closed this as completed May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants