0
votes

I'm new to Scala, coming from a beginner Java background, so please bear with me.

I have a class, Arbitrage, with an abstract subclass Builder. I would like Arbitrage's type parameter to extend the abstract subclass.

Ex:

   abstract class Arbitrage[T <: Builder[T]] {
    // lots of code
    abstract class Builder[T]{
        // build pattern code
    }
}

However this does not compile, and IntelliJ informs me that it "Cannot Resolve symbol "Builder". If I change the class signature to

class Arbitrage[T <: Ordered[T]] 

then it compiles, so I'm fairly sure it's an issue with visibility.

Regards

1
What are you trying to do with this? - Michael Zajac
@m-z Alright so, the abstract class arbitrage, and its subclass Builder are a format for a variety of classes that will extend Arbitrage. let's call them SpacialArbitrage, MergerArbitrage and BondArbitrage. They will all extend Arbitrage and their respective builders will extend Arbitrage's builder, so they're easier to write. The "builders" are, as you might guess, following the Java Builder pattern. - sudom82

1 Answers

0
votes

I solved my problem:

I was using Java syntax for accessing subclasses, e.g., Arbitrage.Builder, what I needed was Arbitrage#Builder, this is the Scala syntax.