alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (bug1957.scala)

This example Scala source code file (bug1957.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

grist, grist, list, list, module, module, settings, settings, test, tool

The Scala bug1957.scala source code

object Test {
    abstract class Settings {}

    abstract class Grist
    { self =>
        type settingsType <: Settings
        type moduleType <: Module {type settingsType = self.settingsType}
        val module: moduleType
    }

    abstract class Tool
    { self =>
        type settingsType <: Settings
        type moduleType = Module { type settingsType = self.settingsType }
        type gristType = Grist { type moduleType <: self.moduleType; type settingsType <: self.settingsType }

        def inputGrist: List[gristType]
    }

    abstract class Module
    { self =>
        type settingsType <: Settings
        final type commonModuleType = Module {type settingsType = self.settingsType}
        type selfType >: self.type <: commonModuleType

        // BTW: if we use the commented out type declarations, the code compiles successfully
        // type gristType = Grist {type settingsType <: self.settingsType; type moduleType <: commonModuleType }

        val tools: List[Tool {type settingsType = self.settingsType}]

        protected def f: List[commonModuleType] =
        {
            val inputGrists = tools.flatMap(_.inputGrist) // val inputGrists: List[gristType] =
            inputGrists.map(_.module)
        }

    }
}

Other Scala examples (source code examples)

Here is a short list of links related to this Scala bug1957.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.