Skip to content

Commit

Permalink
Add polyfills for below 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
kubukoz committed Jan 19, 2024
1 parent a80d28e commit 3780c74
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions plugin/src/main/scala-3.1.x/ParentTypes.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.polyvariant

import dotty.tools.dotc.core.Symbols.ClassSymbol
import dotty.tools.dotc.core.Contexts.Context
import dotty.tools.dotc.core.Types.Type
import dotty.tools.dotc.core.Types.ClassInfo

extension (clazz: ClassSymbol) {

// 3.1.x/3.2.x doesn't have this method, this is the inlined definition from 3.3.x
def parentTypes(using Context): List[Type] = clazz.info match
case classInfo: ClassInfo => classInfo.declaredParents
case _ => Nil

}
15 changes: 15 additions & 0 deletions plugin/src/main/scala-3.2.x/ParentTypes.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.polyvariant

import dotty.tools.dotc.core.Symbols.ClassSymbol
import dotty.tools.dotc.core.Contexts.Context
import dotty.tools.dotc.core.Types.Type
import dotty.tools.dotc.core.Types.ClassInfo

extension (clazz: ClassSymbol) {

// 3.1.x/3.2.x doesn't have this method, this is the inlined definition from 3.3.x
def parentTypes(using Context): List[Type] = clazz.info match
case classInfo: ClassInfo => classInfo.declaredParents
case _ => Nil

}

0 comments on commit 3780c74

Please sign in to comment.