Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lemastero/589be3f4b0bd46e91045a4b22ad39d0f to your computer and use it in GitHub Desktop.
Save lemastero/589be3f4b0bd46e91045a4b22ad39d0f to your computer and use it in GitHub Desktop.
import dotty.tools.dotc.ast.tpd.TypeTree
import dotty.tools.dotc.core.Contexts.Context
import dotty.tools.dotc.core.Symbols.defn
import dotty.tools.dotc.plugins.{PluginPhase, StandardPlugin}
import dotty.tools.dotc.typer.FrontEnd
import dotty.tools.dotc.report
class InferenceMatchablePlugin extends StandardPlugin {
override def name = "inference-matchable-plugin"
override def description = "warn Matchable"
override def init(options: List[String]): List[PluginPhase] = {
(new InferenceMatchablePhase()) :: Nil
}
}
class InferenceMatchablePhase extends PluginPhase {
override def phaseName = "inference-matchable"
override val runsAfter = Set(FrontEnd.name)
override def prepareForTypeTree(tree: TypeTree)(using context: Context): Context = {
if (tree.tpe == defn.MatchableType) {
report.warning("Matchableに推論されてるぞ!!!", tree.srcPos)
}
context
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment